from twisted.web.resource import Resource


class BaseResource(Resource):
    def __init__(self):
        """Initialize the resource.
        """
        self.children = {}
        self.request = None

    def render_GET(self, request):
        self.request = request
        return self.doGet()

    def render_POST(self, request):
        self.request = request
        return self.doPost()

    def doGet(self):
        return "GET"

    def doPost(self):
        return "POST"

    def getCookie(self, k):
        return self.request.getCookie(k)

    def addCookie(self, k, v):
        self.request.addCookie(k, v)

    def getClientIP(self):
        return self.request.getClientIP()
